#include "includes.h"
#include "drivers.h"
#include "data.h"

/* amp[0]: left(C2) ADC0_SE11
 * amp[1]: right(B1) ADC0_SE9
 * amp[2]: left_head(E20) ADC0_DADP0
 * amp[3]: right_head(E22) ADC0_DADP3
 */
uint16 amp[4];
const uint8_t ad_ch[AMP_ADC_CHN+1]={ADC_AD9, ADC_AD11, ADC_DADP3, ADC_DADP0, 0x1F};

void dma_adc_activate(void){
    DMA_CLEAR_FLAG(DMA_CH0);
    DMA_CLEAR_FLAG(DMA_CH1);

    DMA_DAR_SET(DMA_CH0, (uint32_t)&amp);
    DMA_SAR_SET(DMA_CH1, (uint32_t)&ad_ch);
    DMA_BCR_SET(DMA_CH0, DMA_ADC_CHN<<1);
    DMA_BCR_SET(DMA_CH1, DMA_ADC_CHN+1);

    DMA_START(DMA_CH1);
}

/* cnt[0]: left(B16) TPM_CLKIN0
 * cnt[1]: right(C5) LPTMR_ALT2
 */
uint16 cnt[2];

void speed_evaluate(void){
    cnt[0]=tpm_cnt_read(TPM2);
    cnt[1]=lptmr_read();
}
